<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 边界符 ^(首) $(尾)
        var rg = /abc/; //正则表达式里面不需要加引号 不管是数值型还是字符串型
        // /abc/ 只要包含abc这个字符串返回的都是true
        console.log(rg.test("abc")); //true
        console.log(rg.test("abdc")); //false
        console.log(rg.test("aabcd")); //true
        console.log('-----------------');
        var reg = /^abc/; //以abc开头
        console.log(reg.test("abc")); //true
        console.log(reg.test("abdc")); //false
        console.log(reg.test("aabcd")); //false
        console.log('-----------------');
        var reg1 = /^abc$/; //精确匹配 要求必须是abc字符串才符合规范
        console.log(reg1.test("abc")); //true
        console.log(reg1.test("abdc")); //false
        console.log(reg1.test("aabcd")); //false
        console.log(reg1.test("abcabc")); //false
    </script>
</body>

</html>